#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 1e6+10;

int l[N<<1],r[N<<1],mx[2],a[N],n,k,s[N];
char S[N];

void upd(int x,int L,int R){if(x > mx[x & 1]) mx[x & 1] = x,l[x] = L,r[x] = R;}

void inherit(int x){
	int L = l[x + 2],R = r[x + 2]; if(!L || !R) return;
	if(a[L] == 2) L++;else if(a[R] == 2) R--;else L++,R--; l[x] = L;r[x] = R;
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,k = in; scanf("%s",S + 1); for(int i = 1;i <= n;i++) a[i] = (S[i] == 'T') + 1;
	for(int i = 1;i <= n;i++) s[i] = s[i-1] + a[i];
	for(int i = 1;i <= n;i++) upd(s[n] - s[i],i + 1,n) , upd(s[n - i],1,n - i); upd(s[n],1,n);
	for(int i = s[n];i >= 1;i--) inherit(i);
	while(k--){int x = in; if(x > mx[x&1]) puts("NIE");else printf("%d %d\n",l[x],r[x]);}
	return 0;
}

